package Graph;

public class MyQueue {
	private int MaxSize;
	private int realsize;
	private int array[];
	private int font;
	private int end;

	public MyQueue(int max) {
		this.MaxSize = max;
		this.realsize = 0;
		this.font = 0;
		this.end = -1;
		array = new int[MaxSize];
	}

	public void InQueue(int value) {
		if (end == MaxSize - 1) {
			end = -1;
		}
		array[++end] = value;
		realsize++;
	}
	public void yxInQueue(int value)
	{
		int i;
		for(i=0;i<realsize;i++)
		{
			if(value>array[i])
			{
				break;
			}
		}
		for(int j=realsize;j>i;j--)
		{
			array[j]=array[j-1];
		}
		array[i]=value;
		realsize++;
	}
	public int yxDeQueue()
	{
		int temp=array[realsize-1];
		realsize--;
		return temp;
		
	}
	
	public int DeQueue() {

		int temp = array[font++];
		if (font == MaxSize) {
			font = 0;
		}
		realsize--;
		return temp;
	}

	public int size() {
		return realsize;
	}

	public boolean isEmpty() {
		return realsize == 0;
	}

	public boolean isFull() {
		return realsize == MaxSize;
	}
}